package 面试真题;

import java.util.Arrays;

/**
 * @author 帅小伙
 * @date 2022/1/22
 * @description
 */
public class Demo03腾讯2017暑假实习生编程题 {


    public String solution(int[] arr){
        Arrays.sort(arr);
        int min = Integer.MAX_VALUE,max = Integer.MIN_VALUE;

        for (int i = 1; i < arr.length; i++) {
            if(min > arr[i] - arr[i-1]) min = arr[i] - arr[i-1];
            if(max < arr[i] - arr[i-1]) max = arr[i] - arr[i-1];
        }


        int maxc = 0,minc = 0;
        for (int i = 0; i < arr.length; i++) {
            for (int j = i+1; j < arr.length; j++) {
                if(arr[j] - arr[i] == min) minc++;
                if(arr[j] - arr[i] == max) maxc++;
            }
        }
        return minc+" "+maxc;
    }
}
